package com.atguigu.gmall.cart.rpc;

import com.atguigu.gmall.cart.service.CartService;
import com.atguigu.gmall.common.result.Result;
import com.atguigu.gmall.common.util.AuthUtil;
import com.atguigu.gmall.model.cart.CartItem;
import com.atguigu.gmall.model.to.UserAuthTo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.context.request.RequestAttributes;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * @author A
 * @version 1.0
 * @description: TODO
 * @date 2025/9/9 23:05
 */
@RestController
@RequestMapping("/rpc/inner/cart")
public class CartRpcController {
    @Autowired
    CartService cartService;
    //添加购物车
    @GetMapping("/addCart")
    public Result<CartItem> addCart(@RequestParam("skuId") Long skuId,
                                    @RequestParam("skuNum") Integer skuNum){

        CartItem cartItem=cartService.addCart(skuId, skuNum);
        return Result.ok(cartItem);
    }
    @DeleteMapping("/deleteChecked")
    public Result deleteChecked(){
        cartService.deleteChecked();
        return Result.ok();
    }
    @GetMapping("/getCheckedCartItems")
    public List<CartItem> getCheckedCartItems(){
        List<CartItem> cartItemList=cartService.getCheckedCartItems();
        return cartItemList;
    }
}
